import 'package:efood_multivendor/data/api/api_client.dart';
import 'package:efood_multivendor/data/model/response/userinfo_model.dart';
import 'package:efood_multivendor/util/app_constants.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:get/get_connect/http/src/response/response.dart';
import 'package:image_picker/image_picker.dart';

class UserRepo {
  final ApiClient apiClient;
  UserRepo({required this.apiClient});

  Future<Response> getUserInfo() async {
    return await apiClient.getData(AppConstants.CUSTOMER_INFO_URI);
  }

  Future<Response> updateProfile(
      UserInfoModel userInfoModel, XFile? data, String token) async {
    Map<String, String> _body = Map();
    _body.addAll(<String, String>{
      'f_name': userInfoModel.fName ?? '',
      'date_of_birth': userInfoModel.birthDate ?? '',
      'alternative_phone': userInfoModel.alternativePhone ?? '',
      if (userInfoModel.driverLanguagePreference != null)
        'english_speaker': userInfoModel.driverLanguagePreference.toString(),
      if (userInfoModel.appLanguage != null)
        'app_language': userInfoModel.appLanguage.toString(),
    });
    return await apiClient.postMultipartData(AppConstants.UPDATE_PROFILE_URI,
        _body, data == null ? [] : [MultipartBody('image', data)]);
  }
}
